package cn.iocoder.yudao.module.indicator.controller.admin.element;

import cn.iocoder.yudao.module.indicator.service.element.ElementService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.indicator.domain.dto.ElementDataDto;
import cn.iocoder.yudao.module.indicator.domain.entity.ElementData;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author ZYW
 * @description: 元素信息管理
 * @date 2023-12-26 9:59
 */
@RestController
@RequestMapping("/elementData")
public class ElementController {

    @Autowired
    ElementService elementService;

    @PostMapping("/insertElement")
    @Operation(summary = "新增元素")
    public CommonResult<Integer> insertElement(ElementDataDto elementDataDto) {
        Integer count = elementService.insertElementData(elementDataDto);
        return success(count);
    }

    @PostMapping("/updateElement")
    @Operation(summary = "修改元素")
    public CommonResult<Integer> updateElement(ElementDataDto elementDataDto) {
        Integer count = elementService.updateElementData(elementDataDto);
        return success(count);
    }
    @GetMapping("/deleteElement")
    @Operation(summary = "删除元素")
    public CommonResult<Integer> deleteElement(String id) {
        Integer count = elementService.deleteElementData(id);
        return success(count);
    }

    @GetMapping("/queryElementList")
    @Operation(summary = "/获得元分页列表")
    public CommonResult<PageResult<ElementData>> getDictTypePage(ElementDataDto elementDataDto) {
        PageResult<ElementData> pageResult = elementService.getDictDataPage(elementDataDto);
        return success(BeanUtils.toBean(pageResult, ElementData.class));
    }

}
